/*
 * usart_buffer.h
 * Project: wifi_module_code
 * Created on: Apr 6, 2013
 * Author: vagabond
 */

#ifndef USART_BUFFER_H_
#define USART_BUFFER_H_


/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
#define BUFFER_SIZE   1024	/*** Must be a power of 2 (2,4,8,16,32,64,128,256,512,...) ***/
#if BUFFER_SIZE < 2
#error BUFFER_SIZE is too small.  It must be larger than 1.
#elif ((BUFFER_SIZE & (BUFFER_SIZE-1)) != 0)
#error BUFFER_SIZE must be a power of 2.
#endif

/**
 * A Struct to represent usart buffer
 */
typedef struct {
	int in;  /**< Next In Index */
	int out; /**< Next Out Index */
	int8_t buf[BUFFER_SIZE]; /**< Buffer */
} usart_buffer;

/* Exported variables --------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */

#endif /* USART_BUFFER_H_ */
